package com.atguigu.lease.common.exception;

import com.atguigu.lease.common.result.ResultCodeEnum;
import lombok.Data;
import org.springframework.stereotype.Component;

/**
 * @author 李俊伟
 * @date 2024/12/22 20:06
 */

@Data
public class LeaseException extends RuntimeException {
    public Integer code;
    /**
     * 通过状态码和错误消息创建异常对象
     * @param message
     * @param code
     */
    public LeaseException(Integer code, String message) {
        super(message);
        this.code = code;
    }

    // * 根据响应结果枚举对象创建异常对象
    public LeaseException(ResultCodeEnum resultCodeEnum) {
        super(resultCodeEnum.getMessage());
        this.code = resultCodeEnum.getCode();
    }
}